<?php
class OauthApp extends ECBaseApp {
	function index() {
		import('WxPayPubHelper/WxPayPubHelper');
		$jsApi = new JsApi_pub();
		//=========步骤1：网页授权获取用户openid============
		//通过code获得openid
		if (!isset($_GET['code'])) {
			//触发微信返回code码
			$retUrl = urlencode("http://m.zimaozhigou.com/index.php?app=oauth");
			$url = $jsApi -> createOauthUrlForCode($retUrl);
			header("Location: $url");
		} else {
			//获取code码，以获取openid
			$code = $_GET['code'];
			$jsApi -> setCode($code);
			$openid = $jsApi -> getOpenId();
//			echo $openid;
		}
	}
}
?>
